from  database import db
from sqlalchemy import Column, DateTime, String, Integer, func, ForeignKey, Numeric
from .product import Product
from .member import Member
from sqlalchemy.orm import relationship


class Offer(db.Model):
    STATUS_NORMAL = "normal"
    id = Column(Integer(), primary_key=True,autoincrement=True)
    status = Column(String(20), default='normal')
    count = Column(Integer(), default=0)
    sales_count = Column(Integer(), default=0)
    slug = Column(String(20), nullable=True)
    product_id = Column(ForeignKey(Product.id))
    price = Column(Numeric(precision=15,scale=4),nullable=False)
    dealer_id = Column(ForeignKey(Member.id))
    mask = Column(String(128), nullable=True)
    updated_at = Column(DateTime(), default=func.now())
    created_at = Column(DateTime(), default=func.now())
    product = relationship(Product)
    dealer = relationship(Member)
